__author__ = 'Textile & ZeroChaos'
import argparse
from scapy.all import *
import pdb


class DeauthParser:
    """
    Parse a pcap and tracket the deauth packets
    Attributes:
        pcap_name: Name of pcap name to open as a string
    """
    def __init__(self, usr_pcap):
        self.__pcap_name = usr_pcap
        self.__deuath_list = list()

    def __get_pcap_packets(self):
        return rdpcap(self.__pcap_name)

    def __find_deauth_packets(self, scapy_object):
        """
        iter over a pcap and strip out all deauth packets for later processing
        """
        for pkt in scapy_object:
            pdb.set_trace()
            self.__deuath_list.append(pkt)

    def process_packets(self):
        """
        process a given pcap and create Deauth Tracker Objects
        """
        # open pcap up and pass it to preparser
        self.__find_deauth_packets(self.__get_pcap_packets())


class DeviceDeauthTracker:
    """
    Track Packets and determine if a device is getting spoofed deauth packets
    or is likely to be generating them
    Attributes:
        Device Mac: sting of hex bytes ie. \xDE\xEA\xDB\xEE\xF0\x00
    """
    def __init__(self, device_mac):
        self.__device_mac = device_mac

    def get_device(self):
        """
        Args:
            None
        Returns:
            Returns device mac as hex bytes \xDE\xEA\xDB\xEE\xF0\x00
        """
        return self.__device_mac


def what_main(usr_args):
    """
    Main of sid
    Args:
        usr_args: Argparse object of user args

    """
    packet_parser = DeauthParser(usr_args.pcap_name)
    packet_parser.process_packets()

if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='Hunt Down Mac addresses that are Deauthing')
    parser.add_argument('-p', '--pcap', help='Pcap to process', nargs=1,
                        dest='pcap_name', requred=True, type=str)
    args = parser.parse_args()
    what_main(args)
    pass